import styles from "./index.module.scss";
import { Pagination, Select } from "antd";
import { useDispatch, useSelector } from "react-redux";
import closeBtn from "@/assets/public/close-btn.png";
import closeBtnLight from "@/assets/public/close-btn-light.png";
import searchBtn from "@/assets/public/icon-search.png";
import searchBtnLight from "@/assets/public/icon-search-light.png";
import { setLayers, setLayersLevel2 } from "@/store";
import EchartsEL from "./echartsEL";
import TreeAreaModel from "@/component/treeAreaModel";

export default function Model(props) {
  const xAxisData = ["四川", "重庆", "北京", "浙江"];
  const seriesData = [100, 52, 200, 334];
  const colorArr = [
    ["rgba(0, 147, 221, 1)", "rgba(255, 255, 255, 1)"],
    ["rgba(0, 147, 221, 1)", "rgba(0, 88, 255, 0.60)"],
    ["rgba(0, 147, 221, 1)", "rgba(0, 88, 255, 0.40)"],
    ["rgba(10, 49, 108, 0.60)", "rgba(27, 101, 155, 0.60)"],
  ];
  const textColor = "rgba(37, 76, 112, 1)";
  const dispatch = useDispatch();
  const { name } = props;
  const layers = useSelector((state) => {
    return state.layers;
  });
  const theme = useSelector((state) => state.theme);
  const handleClose = () => {
    dispatch(
      setLayers({
        query: {},
        name: "",
        other: {},
      })
    );
  };

  const handleOpen = (name) => {
    dispatch(
      setLayersLevel2({
        query: {},
        name,
        other: {},
      })
    );
  };

  const getValue = (value) => {
    console.log(value);
  };

  return (
    <div className={styles.model}>
      <header className={styles.header}>
        {theme ? (
          <img
            style={{
              width: "20px",
              height: "22px",
            }}
            onClick={handleClose}
            src={closeBtnLight}
            alt="加载中..."
          />
        ) : (
          <img
            style={{
              width: "20px",
              height: "22px",
            }}
            onClick={handleClose}
            src={closeBtn}
            alt="加载中..."
          />
        )}
        <span className={styles.title}>{name}</span>
      </header>
      <div className={styles.echarts}>
        <EchartsEL
          textColor={theme ? textColor : "#fff"}
          xAxisData={xAxisData}
          colorArr={colorArr}
          seriesData={seriesData}
        ></EchartsEL>
      </div>

      <div className={styles.searchBox}>
        <div className={styles.inputContainer}>
          <TreeAreaModel> </TreeAreaModel>
          <input
            className={styles.input}
            type="text"
            placeholder="请输入姓名"
          />
          <div className={styles.searchBtn}>
            <span>搜索</span>
            {theme ? (
              <img
                className={styles.searchBtnImg}
                src={searchBtnLight}
                alt="加载中..."
              />
            ) : (
              <img
                className={styles.searchBtnImg}
                src={searchBtn}
                alt="加载中..."
              />
            )}
          </div>
        </div>
        <div className={styles.listHeader}>
          <div className={styles.listItem}>姓名</div>
          <div className={styles.listItem}>部门</div>
          <div className={styles.listItem}>一级项目名称</div>
          <div className={styles.listItem}>二级项目名称</div>
          <div className={styles.listItem}>区域</div>
          <div className={styles.listItem}>员工编号</div>
          <div className={styles.listItem}>直属主管</div>
          <div className={styles.listItem}>异常打卡天数</div>
        </div>
        {[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map((item) => {
          return (
            <div className={styles.list} key={item}>
              <div className={styles.listItem}>
                <span className="text-overflow">姓名</span>
              </div>
              <div className={styles.listItem}>
                <span className="text-overflow">部门</span>
              </div>
              <div className={styles.listItem}>
                <span className="text-overflow">一级项目名称</span>
              </div>
              <div className={styles.listItem}>
                <span className="text-overflow">二级项目名称</span>
              </div>
              <div className={styles.listItem}>
                <span className="text-overflow">区域</span>
              </div>
              <div className={styles.listItem}>
                <span className="text-overflow">员工编号</span>
              </div>
              <div className={styles.listItem}>
                <span className="text-overflow">直属主管</span>
              </div>
              <div className={styles.listItem}>
                <span className="text-overflow">异常打卡天数</span>
              </div>
            </div>
          );
        })}
      </div>
      <div className={styles.pagination}>
        <Pagination
          total={805}
          showTotal={(total) => `共 ${total} 条`}
          defaultPageSize={20}
          defaultCurrent={1}
        />
      </div>
    </div>
  );
}
